package aidturith.db.beans;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name = "subtitle_table")
public class Subtitle {

	@Id
	@GeneratedValue
	@Column(name = "subtitle_id")
	private int subtitle_id;

	@Column(name = "subtitle_name", nullable = false, updatable = true, unique = false)
	private String subtitle_name;

	@Column(name = "subtitle_type", nullable = true, updatable = true, unique = false)
	private String subtitle_type;

	@Column(name = "subtitle_description", nullable = true, updatable = true, unique = false)
	private String subtitle_description;

	@ManyToOne
	@JoinColumn(name = "id_game")
	private Game game;

	@ManyToMany(mappedBy="subtitles")
	private Set<Music> musics = new HashSet<Music>();

	@ManyToMany(cascade = {javax.persistence.CascadeType.ALL})
	@JoinTable(name="composer_subtitle_table",
	joinColumns={@JoinColumn(name="subtitle_id")},
	inverseJoinColumns={@JoinColumn(name="artist_id")})
	private Set<Artist> composers = new HashSet<Artist>();

	@OneToMany(mappedBy="subtitle")
	@Cascade({CascadeType.ALL})
	private Set<Alias> aliases = new HashSet<Alias>();

	public Subtitle() {
		super();
	}

	public Subtitle(String subtitle_name) {
		super();
		this.subtitle_name = subtitle_name;
	}

	public String getSubtitle_name() { return subtitle_name; }
	public void setSubtitle_name(String subtitle_name) { this.subtitle_name = subtitle_name; }

	public String getSubtitle_type() { return subtitle_type; }
	public void setSubtitle_type(String subtitle_type) { this.subtitle_type = subtitle_type; }

	public String getSubtitle_description() { return subtitle_description; }
	public void setSubtitle_description(String subtitle_description) { this.subtitle_description = subtitle_description; }

	public Game getGame() { return game; }
	public void setGame(Game game) { this.game = game; }

	public Set<Music> getMusics() { return musics; }
	public void setMusics(Set<Music> musics) { this.musics = musics; }

	public Set<Artist> getComposers() { return composers; }
	public void setComposers(Set<Artist> composers) { this.composers = composers; }

	public Set<Alias> getAliases() { return aliases; }
	public void setAliases(Set<Alias> aliases) { this.aliases = aliases; }

	@Override
	public String toString() { return subtitle_name; }

}
